<template>
  <div>
    <div class="web-login">
      <div class="logo">
        <img src="../assets/logo.png" alt="">
      </div>
      <div class="login-form">
        <van-form @submit="onSubmit">
          <van-field
            v-model="phone"
            name="手机号"
            label="手机号："
            placeholder="请填写手机号"
            :rules="[{ required: true, message: '请填写手机号' }]"
          />
          <van-field
            v-model="password"
            type="password"
            name="密码"
            label="密码："
            placeholder="请填写密码"
            :rules="[{ required: true, message: '请填写密码' }]"
          />
          <div class="subbutton">
            <van-button round block type="info" native-type="submit">登录</van-button>
          </div>
        </van-form>
      </div>
    </div>
    <div class="tips">
      <span>tips:</span>
      <span>测试账号:18888888888</span>
      <span>密码:123456</span>
    </div>
    <div class="arrow-left" @click="$router.replace('/center')">
      <img src="../assets/arrowleft.png" alt="">
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      phone: '',
      password: ''
    }
  },
  methods: {
    onSubmit() {
      if (this.phone == '18888888888' && this.password == '123456') {
        this.$store.commit('changeLogin', true)
        this.$router.back()
        this.$toast('登陆成功')
      } else {
        this.$toast('手机号或密码不正确')
        this.phone = ''
        this.password = ''
      }
    }
  }
}
</script>

<style scoped>
.logo {
  margin: .79rem auto .40rem;
  text-align: center;
  height: .60rem;
  line-height: .60rem;
}
.logo img {
  height: .60rem;
}




.van-field {
  margin-bottom: .20rem;
  font-size: .14rem;
}
.subbutton {
  margin-top: .60rem;
}
.van-button {
  width: 80%;
  margin: 0 auto;
  background: #ff5f16;
  border: 0;
  font-size: .16rem;
  height: .47rem;
}




.arrow-left  {
  position: absolute;
  top: 2%;
  left: 2%;
  width: .35rem;
  height: .35rem;
}
.arrow-left img {
  width: 100%;
  display: block;
}



.tips {
  position: absolute;
  display: flex;
  width: 90%;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  background: #f4f4f4;
  color: #797d82;
  font-size: .12rem;
  padding: .10rem;
  border-radius: .50rem;
}
.tips span:nth-of-type(1) {
  width: 20%;
}
.tips span:nth-of-type(2) {
  flex: 1;
}
.tips span:nth-of-type(3) {
  width: 30%;
}
</style>